/**
 *  Copyright (C) 2008-2013  Telosys project org. ( http://www.telosys.org/ )
 *
 *  Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *          http://www.gnu.org/licenses/lgpl.html
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.telosys.persistence;

import org.telosys.common.data.BeanList;


/**
 * Query interface for an entity managed by a DAO
 * 
 * @author Laurent GUERIN
 * 
 */
public interface Query<T>
{
    /**
     * Returns the class of the entity bean managed by this query 
     * @return the class
     */
    Class<T> getEntityBeanClass();
	
    /**
     * Creates a new void list of entity bean
     * @return
     */
    BeanList<T> createList();

    /**
     * Returns the SQL request "select ... from ..."
     * @return the SQL request
     */
    String getSqlSelect();

    /**
     * Returns the SQL request "delete from ..."
     * @return the SQL request
     */
    String getSqlDelete();

    /**
     * Returns the SQL request "select count(*) from ..."
     * @return the SQL request
     */
    String getSqlCount();

    //---------------------------------------------------------------------------
    
    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, Object value);

    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, byte value);
    
    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, short value);
    
    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, int value);

    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, long value);
    
    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, float value);
    
    /**
     * Set the value of a parameter 
     * @param index index of the parameter to set ( 1 to N ) 
     * @param value value of the parameter
     */
    void setParameter(int index, double value);
    
    //---------------------------------------------------------------------------
    /**
     * Returns the number of parameters for the query
     * @return the parameters count
     */
    int getParamCount();

    //---------------------------------------------------------------------------
    
    /**
     * Get the value of a parameter 
     * @param index index of the parameter ( 1 to N ) 
     * @return the value
     */
    Object getParameter(int index);

//    /**
//     * Return the query parameters as an array <br> 
//     * ( the first useful parameter is at index 1 )
//     * @return
//     */
//    public Object[] getParametersArray();

    /** 
     * Returns the query parameters as a String
     * @return the parameters
     */
    String getParametersString();
    
    /**
     * Returns true if all the query parameters have been set 
     * @return true if the query is ready for execution
     */
    boolean allParametersInitialized();

}